/* eslint-disable class-methods-use-this */
import {
  get,
  put,
  _delete,
} from '@/lin/plugins/axios'

// 我们通过 class 这样的语法糖使模型这个概念更加具象化，其优点：耦合性低、可维护性。
class Partner {
  async getProvinceList(page, limit, info) {
    const res = await get(`v1/partner/province?page=${page}&limit=${limit}`, info)
    return res
  }

  async getProvinceInfo(id) {
    const res = await get(`v1/partner/province/${id}`)
    return res
  }

  async updateProvince(info) {
    const res = await put('v1/partner/province', info)
    return res
  }

  async deleteProvince(id) {
    const res = await _delete(`v1/partner/province/${id}`)
    return res
  }

  async getCityList(page, limit, info) {
    const res = await get(`v1/partner/city?page=${page}&limit=${limit}`, info)
    return res
  }

  async getCityInfo(id) {
    const res = await get(`v1/partner/city/${id}`)
    return res
  }

  async updateCity(info) {
    const res = await put('v1/partner/city', info)
    return res
  }

  async deleteCity(id) {
    const res = await _delete(`v1/partner/city/${id}`)
    return res
  }

  async getCountyList(page, limit, info) {
    const res = await get(`v1/partner/county?page=${page}&limit=${limit}`, info)
    return res
  }

  async getCountyInfo(id) {
    const res = await get(`v1/partner/county/${id}`)
    return res
  }

  async updateCounty(info) {
    const res = await put('v1/partner/county', info)
    return res
  }

  async deleteCounty(id) {
    const res = await _delete(`v1/partner/county/${id}`)
    return res
  }

  async getAssistantList(page, limit, info) {
    const res = await get(`v1/partner/assistant?page=${page}&limit=${limit}`, info)
    return res
  }

  async getAssistantInfo(id) {
    const res = await get(`v1/partner/assistant/${id}`)
    return res
  }

  async updateAssistant(info) {
    const res = await put('v1/partner/assistant', info)
    return res
  }

  async deleteAssistant(id) {
    const res = await _delete(`v1/partner/assistant/${id}`)
    return res
  }
}

export default new Partner()
